/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.MailConstants;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.util.yauth.MetadataTokenStore;
/*    */ import com.zimbra.cs.util.yauth.TokenAuthenticateV1;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.io.IOException;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetYahooAuthToken
/*    */   extends MailDocumentHandler
/*    */ {
/*    */   private static final String APPID = "ZYMSGRINTEGRATION";
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 40 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 41 */     Mailbox mbox = getRequestedMailbox(zsc);
/*    */     
/* 43 */     MetadataTokenStore mts = new MetadataTokenStore(mbox);
/*    */     
/* 45 */     String userId = request.getAttribute("user");
/* 46 */     String passwd = request.getAttribute("password");
/*    */     
/* 48 */     Element response = zsc.createElement(MailConstants.GET_YAHOO_AUTH_TOKEN_RESPONSE);
/*    */     try
/*    */     {
/* 51 */       String token = TokenAuthenticateV1.getToken(userId, passwd);
/* 52 */       mts.putToken("ZYMSGRINTEGRATION", userId, token);
/* 53 */       if (token == null) {
/* 54 */         response.addAttribute("failed", true);
/*    */       }
/*    */     } catch (IOException e) {
/* 57 */       throw ServiceException.FAILURE("IOException", e);
/*    */     }
/*    */     
/*    */ 
/* 61 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/GetYahooAuthToken.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */